package com.qf.controller;

import com.github.pagehelper.PageInfo;
import com.qf.pojo.Student;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/stu")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/{page}/{size}")
    public PageInfo<Student> findByPage(@PathVariable("page") int page, @PathVariable("size") int size){
        PageInfo<Student> pageInfo = studentService.page(page, size);


        int i = 1/0;

        return pageInfo;
    }

    @GetMapping("/login")
    public void login(HttpServletRequest req){
        //向session中存入一个user信息
        req.getSession().setAttribute("user",new Object());
    }
}
